<?php

/**
 * PageRoute represents a route with a page_id parameter.
 *
 * If not specified when generating an URL, the page_id is automatically added.
 */
class PageRoute extends sfRoute
{
    public function generate($params, $context = array(), $absolute = false)
    {
        if (!isset($params['page_id']) && ($page_id = sfContext::getInstance()->getUser()->getPageId()))
            $params['page_id'] = $page_id;
        return parent::generate($params, $context, $absolute);
    }
}

